<?php
require_once 'phplot/phplot.php';

function preparePlot($data)
{
  $plot = new PHPlot(1400,700);
  $plot->SetDataColors(array('green','red','blue','orange','brown','white','violet'));
  $plot->SetFont('x_label',5);
  $plot->SetFont('y_label',5);
  $plot->SetDataType('text-data');
  $plot->SetIsInline(true);
  $plot->SetDataValues($data);
  return $plot;
}

function multiLineChart($assoc)
{
  $data = array();
  foreach($assoc as $x=>$values)
  {
    $data []= array_merge(array(''),$values);
  }
  $plot = preparePlot($data);
  return $plot;
}

function multiBarChart($assoc)
{
  $data = array();
  foreach($assoc as $x=>$values)
  {
    $data []= array_merge(array($x),$values);
  }
  $plot = preparePlot($data);
  $plot->SetPlotType('stackedbars');
  $plot->SetXTickLabelPos('none');
  $plot->SetXTickPos('none');
  $plot->SetYDataLabelPos('plotstack');
  return $plot;
}

function pieChart($assoc)
{
  $data = array();
  $legend = array();
  foreach($assoc as $x=>$values)
  {
    $data []= array_merge(array(''),$values);
    $legend []=$x;
  }
  $plot = preparePlot($data);
  $plot->SetLegend($legend);
  $plot->SetDataType('text-data-single');
  $plot->SetPlotType('pie');
  return $plot;
}

?>
